/*temp content*/
var Content=React.createClass({displayName: "Content",
	render:function(){
		return (
			React.createElement("div", null)
		)
	}
});

(function(window){
	/*header--NewSocialAccount*/
	var NewSocialAccount=React.createClass({displayName: "NewSocialAccount",
		close:function(){
			Backbone.history.history.back()
		},
		render:function(){
			var type=this.props.type;

			return (
				React.createElement("div", {className: "modal", style: {display:'block'}}, 
					React.createElement("div", {className: "modal-dialog"}, 
						React.createElement("div", {className: "modal-content box"}, 
							React.createElement("div", {className: "modal-header"}, 
								React.createElement("button", {type: "button", className: "close", "data-dismiss": "modal", "aria-label": "Close", onClick: this.close}, 
									React.createElement("span", {"aria-hidden": "true"}, "×")
								), 
								React.createElement("h4", {className: "modal-title"}, "连接微信账号")
							), 
							React.createElement("div", {className: "modal-body"}, 
								React.createElement("div", {className: "nav-tabs-custom"}, 
									React.createElement("ul", {className: "nav nav-tabs"}, 
										type!=2?React.createElement("li", {className: "active"}, React.createElement("a", {href: "#tab_1", "data-toggle": "tab"}, "公众号配置项方式")):'', 
										type!=1?React.createElement("li", {className: type==2?"active":""}, React.createElement("a", {href: "#tab_2", "data-toggle": "tab"}, "一键登录授权")):''
									), 
									React.createElement("div", {className: "tab-content"}, 
										React.createElement("div", {className: type!=2?"tab-pane active":"tab-pane", id: "tab_1"}, 
											React.createElement("form", {className: "form-horizontal"}, 
												React.createElement("div", {className: "box-body"}, 
													React.createElement("div", {className: "form-group"}, 
														React.createElement("label", {htmlFor: "inputEmail3", className: "col-sm-4 control-label"}, "公众账号名称"), 
														React.createElement("div", {className: "col-sm-8"}, 
															React.createElement("input", {type: "text", className: "form-control", id: "inputEmail3", placeholder: "输入一个名字标识你的公众账号名称"})
														)
													), 
													React.createElement("div", {className: "form-group"}, 
														React.createElement("label", {htmlFor: "inputPassword3", className: "col-sm-4 control-label"}, "AppID（应用ID）"), 
														React.createElement("div", {className: "col-sm-8"}, 
															React.createElement("input", {type: "text", className: "form-control", id: "inputPassword3", placeholder: "输入AppID"})
														)
													), 
													React.createElement("div", {className: "form-group"}, 
														React.createElement("label", {htmlFor: "inputEmail3", className: "col-sm-4 control-label"}, "AppSecret（应用秘钥）"), 
														React.createElement("div", {className: "col-sm-8"}, 
															React.createElement("input", {type: "text", className: "form-control", id: "inputEmail3", placeholder: "输入AppSecret"})
														)
													), 
													React.createElement("div", {className: "form-group"}, 
														React.createElement("label", {htmlFor: "inputEmail3", className: "col-sm-4 control-label"}, "URL（服务器地址）"), 
														React.createElement("div", {className: "col-sm-8"}, 
															React.createElement("input", {type: "text", className: "form-control", id: "inputEmail3", disabled: true, placeholder: "http://wxapi.parllay.cn/wechatcallback?token=K31FAYQ398"})
														)
													), 
													React.createElement("div", {className: "form-group"}, 
														React.createElement("label", {htmlFor: "inputEmail3", className: "col-sm-4 control-label"}, "Token（令牌）"), 
														React.createElement("div", {className: "col-sm-8"}, 
															React.createElement("input", {type: "text", className: "form-control", id: "inputEmail3", disabled: true, placeholder: "K31FAYQ398"})
														)
													)
												), 
												React.createElement("div", {className: "box-footer"}, 
													React.createElement("button", {type: "submit", className: "btn btn-primary btn-block"}, "创建公众号连接")
												)
											)
										), 
										React.createElement("div", {className: type==2?"tab-pane active":"tab-pane", id: "tab_2"}, 
											React.createElement("div", {className: "box-body"}, 
												React.createElement("div", {className: "form-group"}, 
													React.createElement("p", null, "烽火台是腾讯一键登录授权官方认证平台。一键登录授权是腾讯为公众号第三方平台提供给公众号运营者在面向垂直行业需求时，可以通过一键登录授权给第三方开发者，来完成相关能力。"), 
													React.createElement("p", null, "一键登录授权的官方说明 ", React.createElement("a", {href: "https://open.weixin.qq.com", target: "_blank"}, "https://open.weixin.qq.com"))
												)
											), 
											React.createElement("div", {className: "box-footer"}, 
												React.createElement("form", {className: "form-horizontal"}, 
													React.createElement("button", {type: "submit", className: "btn btn-primary btn-block"}, "一键登录授权")
												)
											)
										)
									)
								)
							)
						)
					)
				)
			)
		}
	});

	/*header--SocialAccount*/
	var AccountItemPlus=React.createClass({displayName: "AccountItemPlus",
		render:function(){
			var data=this.props.data,
				setSocialAccount=this.props.setSocialAccount,
				openID=this.props.openID;

			return (
				React.createElement("li", {className: "user user-menu user-plus", title: "新增账号"}, 
					React.createElement("a", {href: "#bind-social-account"}, React.createElement("i", {className: "fa fa-plus user-image", alt: "新增账号"}))
				)
			)
		}
	});

	var AccountItem=React.createClass({displayName: "AccountItem",
		setChosen:function(){
			/*var data=this.props.data,
				index=this.props.index,
				setSocialAccount=this.props.setSocialAccount;
			setSocialAccount(data);
			$.ajax({
				type:'post',
				url:'/setsocialaccount',
				data:{chosen:index},
				success:function(data){
					if(!data.error){console.log(data)}
				}
			})*/
		},
		render:function(){
			var data=this.props.data,
				openID=this.props.openID;

			return (
				React.createElement("li", {className: data.openID==openID?"user user-menu active":"user user-menu", onClick: this.setChosen, title: data.name}, 
					React.createElement("a", {href: data.openID==openID?"javascript:void(0)":"index.html"}, React.createElement("img", {src: data.src, className: "user-image", alt: data.name}))
				)
			)
		}
	});

	var SocialAccount=React.createClass({displayName: "SocialAccount",
		getInitialState:function(){
			this.props.aboutSocialAccount.getSocialAccount(this);
			return {
				data:[]
			}
		},
		render:function(){
			var aboutSocialAccount=this.props.aboutSocialAccount,
				setSocialAccount=aboutSocialAccount.setSocialAccount,
				openID=aboutSocialAccount.openID,
				data=this.state.data,
				list=data.map(function(i,index){
					return (
						React.createElement(AccountItem, {key: index, index: index, data: i, setSocialAccount: setSocialAccount, openID: openID})
					)
				});
				list.push(React.createElement(AccountItemPlus, {key: -1}))

			return (
				React.createElement("ul", {className: "nav navbar-nav social-account"}, 
					list
				)
			)
		}
	});	

	/*header--UserAccount*/
	var UserAccount=React.createClass({displayName: "UserAccount",
		getInitialState:function(){
			this.props.getUserInfo(this);
			return {
				name:'获取中..',
				src:'images/default.png',
				date:'--',
				used:'0G',
				total:'0G'
			}
		},
		render:function(){
			var state=this.state;

			return (
				React.createElement("div", {className: "navbar-custom-menu", style: {marginRight:'5px'}}, 
					React.createElement("ul", {className: "nav navbar-nav"}, 
						React.createElement("li", {className: "dropdown user user-menu"}, 
							React.createElement("a", {href: "#", className: "dropdown-toggle", "data-toggle": "dropdown", "aria-expanded": "true"}, 
								React.createElement("img", {src: state.src, className: "user-image", alt: "User Image"}), 
								React.createElement("span", {className: "hidden-xs"}, state.name)
							), 
							React.createElement("ul", {className: "dropdown-menu"}, 
								React.createElement("li", {className: "user-header"}, 
								React.createElement("img", {src: state.src, className: "img-circle", alt: "User Image"}), 
								React.createElement("p", null, 
								state.name, 
								React.createElement("small", null, "注册自 ", state.date)
								)
								), 
								React.createElement("li", {className: "user-body"}, 
									React.createElement("div", {className: "row"}, 
										React.createElement("div", {className: "col-xs-12 text-center"}, 
											"当前空间使用", state.used, " / 共", state.total
										)
									)
								), 
								React.createElement("li", {className: "user-footer"}, 
								React.createElement("div", {className: "pull-left"}, 
								React.createElement("a", {href: "#", className: "btn btn-default btn-flat"}, "修改信息")
								), 
								React.createElement("div", {className: "pull-right"}, 
								React.createElement("a", {href: "/logout", className: "btn btn-default btn-flat"}, "登出账号")
								)
								)
							)
						)
					)
				)
			)
		}
	});
	
	/*header--BusinessAccount*/
	var BusinessItem=React.createClass({displayName: "BusinessItem",
		render:function(){
			var data=this.props.data,
				url=data.active?'javascript:void(0)':data.url;

			return (
				React.createElement("li", null, React.createElement("a", {href: url}, data.name))
			)
		}
	});

	var BusinessAccount=React.createClass({displayName: "BusinessAccount",
		getInitialState:function(){
			this.props.getBusinessAccount(this);
			return {
				data:[]
			}
		},
		render:function(){
			var data=this.state.data,
				businessName='请选择企业账号',
				list=data.map(function(i,index){
					if(i.active){
						businessName=i.name
					}
					return (
						React.createElement(BusinessItem, {key: index, data: i})
					)
				});

			return (
				React.createElement("div", {className: "navbar-custom-menu"}, 
					React.createElement("ul", {className: "nav navbar-nav"}, 
						React.createElement("li", {className: "dropdown"}, 
							React.createElement("a", {href: "#", className: "dropdown-toggle", "data-toggle": "dropdown"}, businessName, " ", React.createElement("span", {className: "caret"})), 
							React.createElement("ul", {className: "dropdown-menu", role: "menu", style: {left:'auto',right:0}}, 
								list
							)
						)
					)
				)
			)
		}
	});

	/*header--main*/
	var Header=React.createClass({displayName: "Header",
		toggle:function(){
			var collapse=document.getElementsByTagName('body')[0].getAttribute('class').indexOf('sidebar-collapse')>=0;
			$.ajax({
				type:'post',
				url:'/setcollapse',
				data:{
					collapse:!collapse
				},
				dataType:'json',
				success:function(data){
					console.log(data)
				}
			})
		},
		render:function(){
			var aboutSocialAccount=this.props.aboutSocialAccount,
				getBusinessAccount=this.props.getBusinessAccount,
				getUserInfo=this.props.getUserInfo;

			return (
				React.createElement("header", {className: "main-header"}, 
					React.createElement("a", {href: "/", className: "logo"}, 
						React.createElement("span", {className: "logo-mini"}, React.createElement("b", null, "峰"), "火台"), 
						React.createElement("span", {className: "logo-lg"}, React.createElement("b", null, "峰"), "火台")
					), 
					React.createElement("nav", {className: "navbar navbar-static-top"}, 
						React.createElement("a", {href: "#", className: "sidebar-toggle", "data-toggle": "offcanvas", role: "button", onClick: this.toggle}, 
							React.createElement("span", {className: "sr-only"}, "Toggle navigation")
						), 
						React.createElement(SocialAccount, {aboutSocialAccount: aboutSocialAccount}), 
						React.createElement("div", {className: "navbar-custom-menu"}, 
							React.createElement("ul", {className: "nav navbar-nav"}, 
								React.createElement(UserAccount, {getUserInfo: getUserInfo})
							)
						)
					)
				)
			)
		}
	});

	/*sidebar*/
	var SubTreeView=React.createClass({displayName: "SubTreeView",
		render:function(){
			var data=this.props.data,
				path=location.pathname,
				title=document.title.split('-')[0],
				active=path.indexOf(data.url)>=0 || title==data.name;
			
			return (
				React.createElement("li", {className: active?"active":""}, 
					React.createElement("a", {href: "/"+data.url}, 
						React.createElement("i", {className: "fa fa-circle-o"}), " ", data.name
					)
				)
			)
		}
	});

	var TreeView=React.createClass({displayName: "TreeView",
		render:function(){
			var data=this.props.data,
				path=location.pathname,
				active=path.indexOf(data.url)>=0,
				subData=data.sub,
				subHtml='';

			if(subData){
				subHtml=React.createElement("ul", {className: "treeview-menu menu-open"}, 
					subData.map(function(i,index){
						return (
							React.createElement(SubTreeView, {key: index, data: i})
						)
					})
				)
			}
			
			return (
				React.createElement("li", {className: active?"treeview active":"treeview"}, 
					React.createElement("a", {href: data.url}, 
						React.createElement("i", {className: "fa "+data.icon}), 
						React.createElement("span", null, " ", data.name), 
						React.createElement("i", {className: "fa fa-angle-left pull-right"})
					), 
					subHtml
				)
			)
		}
	});

	var SidebarMenu=React.createClass({displayName: "SidebarMenu",
		getInitialState:function(){
			this.props.getSideBar(this);
			return {
				data:[]
			}
		},
		render:function(){
			var data=this.state.data.map(function(i,index){
				return (
					React.createElement(TreeView, {key: index, data: i})
				)
			});
			return (
				React.createElement("aside", {className: "main-sidebar"}, 
					React.createElement("section", {className: "sidebar"}, 
						React.createElement("div", {className: "user-panel"}), 
						React.createElement("ul", {className: "sidebar-menu"}, 
							data
						)
					)
				)
			)
		}
	});

	/*wrapper*/
	var ContentHeader=React.createClass({displayName: "ContentHeader",
		render:function(){
			var ele=document.getElementById('wrapper'),
				title=ele.getAttribute('data-title'),
				subtitle=ele.getAttribute('data-subtitle'),
				socialAccount=this.props.socialAccount;

			return (
				React.createElement("section", {className: "content-header"}, 
					React.createElement("h1", null, title, React.createElement("small", null, socialAccount.name))
				)
			)
		}
	});

	var Wrapper=React.createClass({displayName: "Wrapper",
		getInitialState:function(){
			return {
				socialAccount:{
					openID:null
				}
			}
		},
		componentDidMount:function(){
			//$.AdminLTE.layout.fix()
		},
		setSocialAccount:function(account){
			this.setState({
				socialAccount:account
			})
		},
		render:function(){
			var getSideBar=this.props.getSideBar,
				getSocialAccount=this.props.getSocialAccount,
				getBusinessAccount=this.props.getBusinessAccount,
				getUserInfo=this.props.getUserInfo,
				socialAccount=this.state.socialAccount,
				openID=socialAccount.openID,
				contentData=this.props.contentData;

			return (
				React.createElement("div", {className: "wrapper"}, 
					React.createElement(Header, {aboutSocialAccount: {
						getSocialAccount:getSocialAccount,
						setSocialAccount:this.setSocialAccount,
						openID:openID
					}, 
					getBusinessAccount: getBusinessAccount, 
					getUserInfo: getUserInfo}), 
					React.createElement(SidebarMenu, {getSideBar: getSideBar}), 
					React.createElement("div", {className: "content-wrapper", id: "content"}, 
						React.createElement(Content, {options: {
							socialAccount:socialAccount,
							contentData:contentData
						}})
					), 
					React.createElement("div", {id: "modal"})
				)
			)
		}
	});
	
	var components={
		NewSocialAccount:NewSocialAccount,
		AccountItem:AccountItem,
		SocialAccount:SocialAccount,
		UserAccount:UserAccount,
		BusinessItem:BusinessItem,
		BusinessAccount:BusinessAccount,
		Header:Header,
		SubTreeView:SubTreeView,
		TreeView:TreeView,
		SidebarMenu:SidebarMenu,
		ContentHeader:ContentHeader,
		Wrapper:Wrapper
	}

	window.parllayComponents=$.extend((window.parllayComponents||{}),components)

})(window)
